<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:a4j="http://richfaces.org/a4j"
	xmlns:rich="http://richfaces.org/rich">

<ui:composition template="../template.xhtml">
	<ui:define name="content">
		<rich:panel>
			<f:facet name="header">
				<h:outputText value="Add new ordered item" />
			</f:facet>
			<h:form>
				<h:panelGrid columns="3">
					<h:outputText value="Ordered item:" />
					<rich:select id="stockTypeSelect"
						value="#{ordersAddItemBean.stockType}"
						converter="#{stockTypeConverter}" required="true"
						requiredMessage="Stock type is required.">
						<f:selectItems value="#{ordersAddItemBean.nonOrderedStockTypes}"
							var="stockType"
							itemLabel="#{stockType.name} (#{stockType.productClass}. class)"
							itemValue="#{stockType}" itemValueAsString="#{stockType.id}" />
					</rich:select>
					<rich:message for="stockTypeSelect" />

					<h:outputText value="Amount:" />
					<h:inputText id="amount" required="true"
						value="#{ordersAddItemBean.amount}"
						requiredMessage="Amount is required."
						converterMessage="Amount value must be number."
						validatorMessage="Amount must be bigger than zero">
						<f:converter converterId="javax.faces.BigDecimal" />
						<f:validateLongRange minimum="1" />
					</h:inputText> kg
					<rich:message for="amount" />

					<f:facet name="footer">
						<h:commandButton action="#{ordersAddItemBean.submit}"
							value="Add item" />
						<h:commandButton action="back" value="Cancel" immediate="true" />
					</f:facet>
				</h:panelGrid>
			</h:form>
		</rich:panel>
	</ui:define>
</ui:composition>
</html>